﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_hy_kitsendus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedHyKitsendus))]
    public class DetailandmedHyKitsendusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedHyKitsendus clazz;
        
        public DetailandmedHyKitsendusSerializer(IDetailandmedHyKitsendus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Tyyp!=null) {
                Writer.WriteStartElement("tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TyypTekstina!=null) {
                Writer.WriteStartElement("tyyp_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TyypTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Sisu!=null) {
                Writer.WriteStartElement("sisu");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Sisu))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_hy_kitsendus>tyyp");
                }
                clazz.Tyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tyyp")).Value;
            }
            if (Reader.LocalName=="tyyp_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_hy_kitsendus>tyyp_tekstina");
                }
                clazz.TyypTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tyyp_tekstina")).Value;
            }
            if (Reader.LocalName=="sisu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_hy_kitsendus>sisu");
                }
                clazz.Sisu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("sisu")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_hy_kitsendus>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_hy_kitsendus>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
